package com.houweishi.module.wageOperateHistroy.controller;

import com.houweishi.common.annotation.Log;
import com.houweishi.common.core.controller.BaseController;
import com.houweishi.common.core.domain.AjaxResult;
import com.houweishi.common.core.page.TableDataInfo;
import com.houweishi.common.enums.BusinessType;
import com.houweishi.common.utils.poi.ExcelUtil;
import com.houweishi.module.wageOperateHistroy.domain.WageOperateHistory;
import com.houweishi.module.wageOperateHistroy.service.IWageOperateHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 工资计算历史Controller
 * 
 * @author yqq
 * @date 2023-06-26
 */
@RestController
@RequestMapping("/module/wageOperateHistroy")
public class WageOperateHistoryController extends BaseController
{
    @Autowired
    private IWageOperateHistoryService wageOperateHistoryService;

    /**
     * 查询工资计算历史列表
     */
    @PreAuthorize("@ss.hasPermi('module:wageOperateHistroy:list')")
    @GetMapping("/list")
    public TableDataInfo list(WageOperateHistory wageOperateHistory)
    {
        startPage();
        List<WageOperateHistory> list = wageOperateHistoryService.selectWageOperateHistoryList(wageOperateHistory);
        return getDataTable(list);
    }

    /**
     * 导出工资计算历史列表
     */
    @PreAuthorize("@ss.hasPermi('module:wageOperateHistroy:export')")
    @Log(title = "工资计算历史", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WageOperateHistory wageOperateHistory)
    {
        List<WageOperateHistory> list = wageOperateHistoryService.selectWageOperateHistoryList(wageOperateHistory);
        ExcelUtil<WageOperateHistory> util = new ExcelUtil<WageOperateHistory>(WageOperateHistory.class);
        util.exportExcel(response, list, "工资计算历史数据");
    }

    /**
     * 获取工资计算历史详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:wageOperateHistroy:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wageOperateHistoryService.selectWageOperateHistoryById(id));
    }

    /**
     * 新增工资计算历史
     */
    @PreAuthorize("@ss.hasPermi('module:wageOperateHistroy:add')")
    @Log(title = "工资计算历史", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WageOperateHistory wageOperateHistory)
    {
        return toAjax(wageOperateHistoryService.insertWageOperateHistory(wageOperateHistory));
    }

    /**
     * 修改工资计算历史
     */
    @PreAuthorize("@ss.hasPermi('module:wageOperateHistroy:edit')")
    @Log(title = "工资计算历史", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WageOperateHistory wageOperateHistory)
    {
        return toAjax(wageOperateHistoryService.updateWageOperateHistory(wageOperateHistory));
    }

    /**
     * 删除工资计算历史
     */
    @PreAuthorize("@ss.hasPermi('module:wageOperateHistroy:remove')")
    @Log(title = "工资计算历史", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wageOperateHistoryService.deleteWageOperateHistoryByIds(ids));
    }
}
